

var api = require('../../utils/api.js');
var app = getApp();

Page({

    /**
     * 页面的初始数据
     */
    data: {
        see:0,
        progressSteps: [
            { label: '1', text: '提交信息', active: true},
            { label: '2', text: '在线支付', active: true},
            { label: '3', text: '专人服务', active: false},
            { label: '4', text: '服务完成', active: false}
        ],
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        var id=options.id;
        console.log('-----------',id);
        var that=this;
        this.setData({
            id:id
        })
        this.getoderbyid();
    },

    getoderbyid(){
        var id=this.data.id;
        var that=this;
        api.post({
            url: 'order/getorderbyid',
            data: {id:id},
            success: data => {
                that.setData({
                    order:data.data.order,
                    progressSteps:data.data.array
                })
            }
        })
    },  
       // 订单完成
       payorder(ret){
        console.log(ret);
        var id=this.data.id;
        var that=this;

        wx.showModal({
          title: '提示',
          content: '确认订单已经完成？',
          complete: (res) => {
            if (res.confirm) {
                api.post({
                    url: 'worker/ordersuccess',
                    data: {id:id},
                    success: data => {
                        that.getoderbyid();
                    }
                })
            }
          }
        })

  

    },
    quxiao(ret){
        var id=this.data.id;
        var that=this;

        wx.showModal({
            title: '退款',
            content: '确认要进行退款',
            complete: (res) => {
                if (res.confirm) {
                    api.post({
                        url: 'order/doRefund',
                        data: {oid:id,types:0},
                        success: data => {
                            console.log(data);
                            that.getoderbyid();
                        }
                    })
                }
            }
        })

    },

    suoding(){
        var id=this.data.id;
        var that=this;

        wx.showModal({
          title: '提示',
          content: '确认要接受此订单？',
          complete: (res) => {
            if (res.confirm) {
                api.post({
                    url: 'worker/suoding',
                    data: {id:id},
                    success: data => {
                        that.getoderbyid();
                    }
                })
            }
          }
        })
    }

})